<?php
###############   COPYLEFT GPLv3 LICENSE   ###############
##
## JFX Version 0.2.9
## Website Management Software
## www.jfxcms.com
##
## Copyright 2009 GPLv3 - http://www.opensource.org/licenses/gpl-3.0.html
##
## Anthony Gallon
## oi_antz@hotmail.com
##
## Permission is hereby granted to any person having a copy of this software
## to freely use and modify as required so long as the copyright notices
## and branding remain intact.
##
## Full license details available at http://www.jfxcms.com/license
##
###############   COPYLEFT GPLv3 LICENSE   ###############

require_once($this->dirname.'/functions/export.php');

if(!$USER->checkAdminPermission('core', 'perm_export_page') &&
    !$USER->checkAdminPermission('core', 'perm_export_block') &&
    !$USER->checkAdminPermission('core', 'perm_import_page') &&
    !$USER->checkAdminPermission('core', 'perm_import_block')){
    
    JFX::addError($this->lang('permission_denied'));
    JFX::redirect($CONFIG->adminUrl);
}

$THEME->addBreadcrumb($this->adminUrl.'/export/', $this->lang('ap_title_export'));

$tabs = array();

if($USER->checkAdminPermission('core', 'perm_export_page')){
    $tabs[] = array(
        'title' => $this->lang('button_export_page'),
        'key' => 'export-page',
        'url' => $CONFIG->adminUrl.'/export/export-page/'
    );
};

if($USER->checkAdminPermission('core', 'perm_export_block')){
    $tabs[] = array(
        'title' => $this->lang('button_export_block'),
        'key' => 'export-block',
        'url' => $CONFIG->adminUrl.'/export/export-block/'
    );
};

if($USER->checkAdminPermission('core', 'perm_import_page')){
    $tabs[] = array(
        'title' => $this->lang('button_import_page'),
        'key' => 'import-page',
        'url' => $CONFIG->adminUrl.'/export/import-page/'
    );
};

if($USER->checkAdminPermission('core', 'perm_import_block')){
    $tabs[] = array(
        'title' => $this->lang('button_import_block'),
        'key' => 'import-block',
        'url' => $CONFIG->adminUrl.'/export/import-block/'
    );
};

if($USER->checkAdminPermission('core', 'perm_import_template')){
    $tabs[] = array(
        'title' => $this->lang('button_import_template'),
        'key' => 'import-template',
        'url' => $CONFIG->adminUrl.'/export/import-template/'
    );
};



$req = explode('?', $_SERVER['REQUEST_URI']);
$req = explode('/', $req[0]);
while($req[0] != trim($CONFIG->adminFolder, '/')){
    array_shift($req);
    $req = array_regenerate_keys($req);
}
array_shift($req);
array_shift($req);
$selectedTab = array_shift($req);
$selectedTab = str_replace('../', '', $selectedTab);

if(strlen(trim($selectedTab))==0){
    $selectedTab = 'export-page';
}


if(file_exists($CONFIG->adminActionsDir.'/export/'.$selectedTab.'.php')){
    include($CONFIG->adminActionsDir.'/export/'.$selectedTab.'.php');
}








